package com.yangye.springclouddemomail.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangye
 * @date 2020/10/27
 */
@RestController
public class MailController {

	@Autowired
	private JavaMailSender mailSender;

	@GetMapping("/sendMail")
	boolean sendMail() {
		SimpleMailMessage msg = new SimpleMailMessage();
		msg.setFrom("283588258@qq.com");
		msg.setTo("woshiyoung@yeah.net");
		msg.setSubject("标题");
		msg.setText("内容");
		mailSender.send(msg);
		return true;
	}
	@GetMapping("/sendMail2")
	boolean sendMail2() {
		SimpleMailMessage msg = new SimpleMailMessage();
		msg.setFrom("enterprise@deepblueai.com");
		msg.setTo("woshiyoung@yeah.net");
		msg.setSubject("标题2");
		msg.setText("内容2");
		mailSender.send(msg);
		return true;
	}
}
